package com.jsy.goods.dao;

import com.jsy.goods.pojo.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

/****
 * @Author:www.jsy.com
 * @Description:Sku的Dao
 * @Date www.jsy.com
 *****/
public interface SkuMapper extends Mapper<Sku> {

    /***
     *扣减库存
     * @param skuId skuId
     * @param num 扣减数量
     * @return 操作结果
     */
    @Update("UPDATE tb_sku SET num=num-#{num},sale_num=sale_num+#{num} WHERE id=#{skuId} AND num>=#{num}")
    int decrCount(@Param("skuId") Long skuId, @Param("num") Integer num);
}
